package ExerciseClass;

import java.util.Scanner;

public class Exercise2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入第一个系数a=");
        int a = scanner.nextInt();
        System.out.print("请输入第二个系数b=");
        int b = scanner.nextInt();
        System.out.print("请输入常数项c=");
        int c = scanner.nextInt();
        int judge = b*b-4*a*c;
        if(judge>0){
            double x1 = (-b+judge)/2.0*a;
            double x2 = (-b-judge)/2.0*a;
            System.out.println("方程有两个解X1,X2");
            System.out.println("方程的解X1="+x1);
            System.out.println("方程的解X2="+x2);
        }else if(judge==0){
            double x = (-b-judge)/2.0*a;
            System.out.println("方程有唯一解X1=X2="+x);
        } else {
            System.out.println("方程无解");
        }
    }
}
